﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using BGM.Domain.DTO;
using System.Linq;
namespace BGM.Application.View
{
    /// <summary>
    /// Interaction logic for DataListUserControl.xaml
    /// </summary>
    internal partial class DataListUserControl : UserControl
    {
        private List<Reading> data;
        public DataListUserControl(List<Reading> data)
        {
            
            this.data = data;
            InitializeComponent();
        }

        private void patientList_Loaded(object sender, RoutedEventArgs e)
        {
            var list = from c in data
                       select new
                       {
                           TimeStamp=c.TimeStamp.ToString(),
                           Value=(c.Value/18.00).ToString("F"),
                           Description=GetHighLow(c.Value)
                       };
            datalistListView.ItemsSource = list;

        }
        private string GetHighLow(double value)
        {
            if (value < 4*18)
                return "Low";
            else if (value > 9*18)
                return "High";
            return string.Empty;
        }
    }
}
